﻿// JavaScript File
/*
处理页面的用户交互事件
Processing Event of User Interactive Operation
*/


var boolResize = false;


//模型选择radio点击控制
function radioCheckModel(event)
{

    
    if(event.data.id == "radioLine")
    {
        if($("#radioLine").attr("checked") == true)
        {
            $("#radioLine").attr("checked",false);
            $("#radioExp").attr("checked",true);
            $("#radioLn").attr("checked",false);
        }
        else
        {
            $("#radioLine").attr("checked",true);
            $("#radioExp").attr("checked",false);
            $("#radioLn").attr("checked",false);
        }
        
    }
    else if (event.data.id == "radioExp")
    {
        if($("#radioExp").attr("checked") == true)
        {
            $("#radioExp").attr("checked",false);
            $("#radioLn").attr("checked",true);
            $("#radioLine").attr("checked",false);
        }
        else
        {
            $("#radioExp").attr("checked",true);
            $("#radioLn").attr("checked",false);
            $("#radioLine").attr("checked",false);
        }        
    }
    else
    {
        if($("#radioLn").attr("checked") == true)
        {
            $("#radioLn").attr("checked",false);
            $("#radioLine").attr("checked",true);
            $("#radioExp").attr("checked",false);
        }
        else
        {
            $("#radioLn").attr("checked",true);
            $("#radioLine").attr("checked",false);
            $("#radioExp").attr("checked",false);
        }            
    }
    

}


/*
User Load Event
*/
function checkUser()
{
     USER_ID = $("#username").attr("value");
     var userPassword = $("#password").attr("value");   
     
     var strURL = "Services/UserCheck.aspx";
     $.ajax({
        async: false,
        cache: false,
        url: strURL,
        data: "NAME=" + USER_ID + "&PWD=" + userPassword + "&TMP=" + Math.random(),
        success: function(data){
                var xmlDocument = data.documentElement;
                var nodeNumber = xmlDocument.childNodes[0].attributes.length;
                if(nodeNumber == 1)
                {
                    alert("您的用户名或密码有错，请重新输入！");
                    return;
                }
                else
                {
                    USER_NAME = xmlDocument.childNodes[0].attributes[0].nodeValue;
                    USER_ROLE_INDEX = xmlDocument.childNodes[0].attributes[1].nodeValue;
                    USER_DISTRICT_ID = xmlDocument.childNodes[0].attributes[2].nodeValue;
                    USER_DISTRICT_NAME = xmlDocument.childNodes[0].attributes[3].nodeValue;
                    USER_EMAIL = xmlDocument.childNodes[0].attributes[4].nodeValue;
                    USER_STATUS = xmlDocument.childNodes[0].attributes[5].nodeValue;
                    USER_LAT = xmlDocument.childNodes[0].attributes[6].nodeValue;
                    USER_LNG = xmlDocument.childNodes[0].attributes[7].nodeValue;
                    USER_ROOTID=xmlDocument.childNodes[0].attributes[8].nodeValue;
                }
                
                 $("#username").attr("value","");
                 $("#password").attr("value","");
                 
                 if(USER_STATUS == "1")
                 {
                     var strLocation = USER_LAT + "," + USER_LNG;
                     if (USER_LAT.length < 2 || USER_LNG.length < 2)
                     {
                        GLoadMap("");
                     }
                     else
                     {
                        GLoadMap(strLocation);
                     }                   
                     
                     var txtWelcome = document.createTextNode(USER_NAME + "，欢迎您使用本系统！");
                     
                     var btnExit = document.createElement("input");
                     btnExit.type = "button";
                     btnExit.value = "退  出";
                     $(btnExit).bind("click",showLoginTable);
                     
                     $("#LoginBar").empty();
                     $("#LoginBar").append(txtWelcome);
                     $("#LoginBar").append(btnExit);  
                     return;
                     
                 }
                 else
                 {
                    alert("您的账户已经过期，请您重新申请或联系管理员！");
                    return;
                 }     
            }
         
         });

}


//显示登陆窗口	
function showLoginTable()
{
    
    //$("#LoginTable").css("visibility","visible");
    $("#LoginBar").empty();
    USER_NAME = "";
    USER_DISTRICT_ID = "";
    USER_ROLE_INDEX = "";
    USER_STATUS = "";
    
    var username = document.createTextNode("用户名：");
    var password = document.createTextNode("密码：");
    var usernameTextbox = document.createElement("input");
    usernameTextbox.type = "text";
    usernameTextbox.id = "username";
    var passwordTextbox = document.createElement("input");
    passwordTextbox.type = "password";
    passwordTextbox.id = "password";
    var loginButton = document.createElement("input");
    loginButton.type = "submit";
    loginButton.value = "登 录";
    $(loginButton).bind("click",checkUser);

    
    var loginTable = document.createElement("table");
    var tbody = document.createElement("tbody");
    loginTable.appendChild(tbody);
    
    tbody.insertRow(0);
    tbody.rows[0].insertCell(0);  
    tbody.rows[0].cells[0].appendChild(username);
    tbody.rows[0].cells[0].appendChild(usernameTextbox);
    tbody.rows[0].insertCell(1);
    tbody.rows[0].cells[1].appendChild(password);
    tbody.rows[0].cells[1].appendChild(passwordTextbox);
    tbody.rows[0].insertCell(2);
    tbody.rows[0].cells[2].appendChild(loginButton);
    
    
    $("#LoginBar").append(loginTable);
    if(typeof(gmap) != "undefined")
    {    
        gmap.clearOverlays();
        $('#wizard').empty();
        $("#DivMenuControl").css("visibility","hidden");
        $("#infoTable").css("visibility","hidden");
        $('#infoTable').empty();
    }
}	


/*
Close Legend Div
*/
function closeLegend()
{
    if($('#legendDiv').children().length > 0)
    {
        $('#legendDiv').empty();
    }
    $('#legendDiv').addClass("legendMin");
    $('#legendDiv').width("4");
    
    resizePage();
    GLoadMap("");
}


/*
Unfold Legend Div
*/
function unfoldLegend()
{
    if(MAP_TYPE == "GMAP" || MAP_TYPE == "GIMAGE")
    {
        alert("您现在并没有使用地图分析功能，因此暂时不能提供图例！");
        return;
    }

    lastMapType = MAP_TYPE; //记录生成图例之前的地图类型；
    //alert($('#legendDiv').width());
    if ($('#legendDiv').width() >10)
    {
        if($('#legendDiv').children().length > 0)
        {
            $('#legendDiv').empty();
        }
        $('#legendDiv').addClass("legendMin");
        $('#legendDiv').width("0");
        $('#legendDiv').css("visibility","hidden");
        
        resizePage();

    }  
    else
    {  
        if($('#legendDiv').children().length > 0)
        {
            $('#legendDiv').empty();
        }
        $('#legendDiv').removeClass();
    //    $('#legendDiv').css("background-image","");
        
        var legendButton1 = document.createElement("span");
        legendButton1.className = "legendbutton";
        legendButton1.id = "close";
        legendButton1.alt = "关闭";
        legendButton1.onclick = closeLegend;

        var legendButton2 = document.createElement("span");
        legendButton2.className = "legendbutton";
        legendButton2.id = "min";        
        
        with($('#legendDiv'))
        {
            append(legendButton1);
            append(legendButton2);
            //append(imgLegend);
            addClass("legend");
            width(250);
            css("visibility","visible");
        }
        resizePage();
        MAP_TYPE = "IMSLEGEND";

        var tempData=$("#forData").data("dt");
	    if(tempData!=undefined)
	    {
		    //alert($("#forData").data("dt"));
		    if(tempData=="disease")
		    {
		        getIMSMap_Disease(MAP_TYPE);
		    }else if(tempData=="AgriQuality")
		    {
		        getIMSMap_AgriQFrc(MAP_TYPE);		        
		    }else if(tempData=="drought") 
            {
                getIMSMap(MAP_TYPE); 
            }
		    else
		    {
		        getIMSMap(MAP_TYPE);
		    }
	    }else
	    {
		    getIMSMap(MAP_TYPE);
	    }

    }   
}


//控制左侧工具栏的显示
function collapseMenuBox()
{
    var leftinfo = $("#leftInfo");
    
    if(leftinfo.width() > 10)
    {
        leftinfo.width(2);
    }
    else
    {
        leftinfo.width(396);
    }   
      
    resizePage();
       
}


function collapseMenu()
{
    $("#wizard").slideToggle("slow");
    flagWizard = !flagWizard;
    var childrenElement = $("#wizard").children(); 
    childrenElement.each(function(){
        if(!flagWizard)
            this.style.visibility = "hidden";
        else
            this.style.visibility = "visible";
    });    
}

/*
resize window
*/

function resizePage()
{
    var i = 0;
    var offsetTop = 0;
    var offsetLeft = 0;
    var mapElem = $("#map");
    var legend = $("#legendDiv");
    var menubox = $("#menuBox");
    var leftControl = $("#leftControl");
    
    
    for (var elem = mapElem; elem && elem.offsetParent.tagName != "body" ; elem = elem.offsetParent()) 
    {
        offsetTop += elem.offset().top;
        offsetLeft += elem.offset().left;
        if(elem.offset().top == 0 && elem.offset().left == 0) break;
    }
    if (offsetLeft < 10 ) offsetLeft = 402;
    var map_height = $(window).height() - offsetTop - 48;
    var map_width = $(window).width() - offsetLeft - 16;
    if(!flagMenu) map_width += 400;
    if (map_height >= 0) 
    {
        mapElem.height(map_height);
        legend.height(map_height);
        menubox.height(map_height + 48);
        leftControl.height(map_height + 48);
    }
    if (map_width>=0)
    {
        if(legend.children().length <2 )
            mapElem.width(map_width - 4);
        else
            mapElem.width(map_width - 268);
    }
    if(typeof(gmap) != "undefined")
        gmap.checkResize();
}


function handleToolClick(event)
{
    var ToolId = event.data.id;

    switch(ToolId)
    {
        case "PanUp":
            gmap.panDirection(0,  -1);
            break;

        case "PanLeft":
            gmap.panDirection(-1,  0);
            break;

        case "PanRight":
            gmap.panDirection(+1,  0);
            break;

        case "LastView":
            gmap.returnToSavedPosition();
            break;

        case "PanDown":
            gmap.panDirection(0,  +1);
            break;

        case "ZoomIn":
            gmap.zoomIn();
            break;

        case "ZoomOut":
            gmap.zoomOut();
            break;

        default:
            break;
        
    }
    gmap.savePosition();
    
    getIMSMap("map");
}

function handleMouseDown()
{
	if(MAP_TYPE == "GMAP") return;
	var eventX;
	var eventY;
	eventX = event.clientX;
	eventY = event.clientY;
	if(EventOverMap(eventX,eventY)) return;
    StartX = eventX;
    StartY = eventY;
    document.getElementById("map").setCapture(); 

}

function handleMouseUp()
{
	if(MAP_TYPE == "GMAP") return;
	var eventX;
	var eventY;
	eventX = event.clientX;
	eventY = event.clientY;
	if(EventOverMap(eventX,eventY)) return;
    EndX = eventX;
    EndY = eventY;
    
    document.releaseCapture();
    
    var xDistance = EndX - StartX;
    var yDistance = EndY - StartY;
    var distanse = new GSize(xDistance,yDistance);
    //var center = gmap.getCenter();
    gmap.panBy(distanse);
    gmap.savePosition();
    
    getIMSMap("map");
    
}


function handleMouseMove()
{

}


function EventOverMap(x,y)
{
    
    var i = 0;
    var offsetTop = 0;
    var offsetLeft = 0;
    
    var mapElem = $("#map");
    
    for (var elem = mapElem; elem; elem = elem.offsetParent()) 
    {
        offsetTop += elem.offset().top;
        offsetLeft += elem.offset().left;
        i++;
        if (i>10) break;
    }
    
    if(x < offsetLeft) return true;
    if(y < offsetTop) return true;
    if(x > (offsetLeft+800)) return true;
    if(y > (offsetTop+500)) return true;
    return false;
}


//********************************灾害监测—病虫害*******************************
//加载病虫害样点观测数据
function loadSamplePointsTable_disease()
{
    var imageId = $("#ImageListSelect").val();

    var type=$("#forDatacache").data("calculateType");
   
    var strURL = "services/getSamplePoints_disease.aspx";
    
    $.get(strURL,{IMAGEID:imageId,TYPE:type,tmp:Math.random()},function(data){
        var xmlDocument = data.documentElement;
        
        var nodes = xmlDocument.getElementsByTagName("Point");
        var nodeNumber = nodes.length;
        if(nodeNumber < 1)
        {
            alert("该区域没有相对应的病虫害样点文件，请重新选择！");
            return;
        }
        
        markerSampleDiseasePoints(xmlDocument);
    });
}

    
//显示病虫害样点
function markerSampleDiseasePoints(xmlDocument)
{     
    var tableTitleNames = new Array("地块编号","经度","纬度","病虫害名称","病情指数");
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    
    var nodes = xmlDocument.getElementsByTagName("Point");
    
    var ParcelsNumber = nodes.length;
    var ParcelsVaule = new Array();
    
    for(var i = 0; i < ParcelsNumber; i++)
    {
        ParcelsVaule[i] = new Array();
        
        for (var j = 0; j < tableTitles.length; j++)
        {
            ParcelsVaule[i][j] = document.createTextNode(nodes[i].attributes[j].nodeValue);
            //ParcelsVaule[i][j] = document.createTextNode(xmlDocument.childNodes[i].attributes[j].nodeValue);
        }
    }   
    
    gmap.clearOverlays();
    var DLon,DLat,MLon,MLat,SLon,SLat;
    var lat = "";
    var lng = "";
    
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var dmsPoint = tranGLatLngToDMS(pointLocation);
        lat = ParcelsVaule[0][2].nodeValue;
        lng = ParcelsVaule[0][1].nodeValue;
        
        var strHtml = "<table><tr><td>";
        strHtml += "地块编号：</td><td>" + ParcelsVaule[i][0].nodeValue + "</td></tr><tr><td>"; 
        strHtml += "经度：</td><td>" + dmsPoint[0] + "</td></tr><tr><td>";   //pointLocation.x  
        strHtml += "纬度：</td><td>" +  dmsPoint[1] + "</td></tr><tr><td>";  //pointLocation.y
        strHtml += "病虫害名称：</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr><tr><td>";
        strHtml += "病情指数：</td><td>" + ParcelsVaule[i][4].nodeValue + "</td></tr>";
        strHtml += "</table>";
        
        createMarker(pointLocation, gmap, strHtml);
    }
    
    //设置地图中心随样点位置而改变
    var centerPoint = new GLatLng(lat, lng);
    gmap.setCenter(centerPoint, 9);  
    
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    //$(table).addClass("viewTable");
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    $("#infoTable").empty();
    document.getElementById("infoTable").appendChild(divTable);
    document.getElementById("infoTable").style.visibility = "visible";
    document.getElementById("DivMenuControl").style.visibility = "visible";
    
}

function markerSampleRSPoints_disease(xmlDocument)
{
    var tableTitleNames = new Array("地块编号","经度","纬度","NDWI", "TVI", "NDVI", "NSI", "WI", "NDGI", "GEMI","EVI","RVI","ARVI","SAVI","MSAVI","DVI","RDVI");

    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    var nodes = xmlDocument.getElementsByTagName("Parcel");
    var ParcelsNumber = nodes.length;//xmlDocument.childNodes.length;   
    
    var ParcelsVaule = new Array();  
    
    for(var i = 0; i < ParcelsNumber; i++)
    {
        ParcelsVaule[i] = new Array();
        ParcelsVaule[i][0] = document.createTextNode(nodes[i].attributes[1].nodeValue);  //pointid
        ParcelsVaule[i][1] = document.createTextNode(nodes[i].attributes[2].nodeValue); //lat
        ParcelsVaule[i][2] = document.createTextNode(nodes[i].attributes[3].nodeValue); //lon
        ParcelsVaule[i][3] = document.createTextNode(nodes[i].attributes[6].nodeValue); //ndwi
        ParcelsVaule[i][4] = document.createTextNode(nodes[i].attributes[7].nodeValue); //tvi
        ParcelsVaule[i][5] = document.createTextNode(nodes[i].attributes[8].nodeValue); //ndvi
        ParcelsVaule[i][6] = document.createTextNode(nodes[i].attributes[9].nodeValue); //NSI
        ParcelsVaule[i][7] = document.createTextNode(nodes[i].attributes[10].nodeValue);//WI
        ParcelsVaule[i][8] = document.createTextNode(nodes[i].attributes[11].nodeValue);//NDGI
        ParcelsVaule[i][9] = document.createTextNode(nodes[i].attributes[12].nodeValue);//GEMI
        ParcelsVaule[i][10] = document.createTextNode(nodes[i].attributes[13].nodeValue);//EVI
        ParcelsVaule[i][11] = document.createTextNode(nodes[i].attributes[14].nodeValue);//,RVI
        ParcelsVaule[i][12] = document.createTextNode(nodes[i].attributes[15].nodeValue);//,ARVI
        ParcelsVaule[i][13] = document.createTextNode(nodes[i].attributes[16].nodeValue);//,SAVI
        ParcelsVaule[i][14] = document.createTextNode(nodes[i].attributes[17].nodeValue);//,MSAVI
        ParcelsVaule[i][15] = document.createTextNode(nodes[i].attributes[18].nodeValue);//,DVI
        ParcelsVaule[i][16] = document.createTextNode(nodes[i].attributes[19].nodeValue);//,RDVI
      
    }
    
    gmap.clearOverlays();
    //var marker = new Array();
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var strHtml = "<table><tr><td>";
        strHtml += "地块编号：</td><td>" + ParcelsVaule[i][0].nodeValue + "</td></tr><tr><td>";
        strHtml += "经度：</td><td>" + pointLocation.x + "</td></tr><tr><td>";
        strHtml += "纬度：</td><td>" + pointLocation.y + "</td></tr><tr><td>";
        strHtml += "RDVI(重归一化植被指数)：</td><td>" + ParcelsVaule[i][16].nodeValue + "</td></tr><tr><td>";
        strHtml += "RVI(比值植被指数)：</td><td>" + ParcelsVaule[i][11].nodeValue + "</td></tr><tr><td>";
        strHtml += "NDVI(归一化植被指数)：</td><td>" + ParcelsVaule[i][5].nodeValue + "</td></tr><tr><td>";
        strHtml += "GEMI(全球环境监测指数)：</td><td>" + ParcelsVaule[i][9].nodeValue + "</td></tr>";
        strHtml += "</table>";
        
        createMarker(pointLocation, gmap, strHtml);

    }
    
    
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    //$(table).addClass("viewTable");
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    
    with($("#infoTable"))
    {
        empty();
        append(divTable);
        css("visibility", "visible");
    }
    $("#DivMenuControl").css("visibility", "visible");
    hideWaitImage();

}


//显示样点高光谱病情指数
function markerSampleRSPoints_HyperDisease(xmlDocument)
{
    var tableTitleNames = new Array("地块编号","经度","纬度","XREDEDGE", "XVALDEPTH", "XWAVELEN", "XWAVEWID","NDWI", "TVI", "NDVI", "NSI", "WI", "NDGI", "GEWI","EVI","RVI","ARVI","SAVI","MSAVI","DVI","RDVI");
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    var nodes = xmlDocument.getElementsByTagName("Parcel");
    var ParcelsNumber = nodes.length;//xmlDocument.childNodes.length;   
    
    var ParcelsVaule = new Array();
    
    for(var i = 0; i < ParcelsNumber; i++)
    {
        ParcelsVaule[i] = new Array();
        ParcelsVaule[i][0] = document.createTextNode(nodes[i].attributes[0].nodeValue);  //pointid
        ParcelsVaule[i][1] = document.createTextNode(nodes[i].attributes[1].nodeValue); //lat
        ParcelsVaule[i][2] = document.createTextNode(nodes[i].attributes[2].nodeValue); //lon
        ParcelsVaule[i][3] = document.createTextNode(nodes[i].attributes[5].nodeValue); //XREDEDGE
        ParcelsVaule[i][4] = document.createTextNode(nodes[i].attributes[6].nodeValue); //XVALDEPTH
        ParcelsVaule[i][5] = document.createTextNode(nodes[i].attributes[7].nodeValue); //XWAVELEN
        ParcelsVaule[i][6] = document.createTextNode(nodes[i].attributes[8].nodeValue); //XWAVEWID
        ParcelsVaule[i][7] = document.createTextNode(nodes[i].attributes[9].nodeValue); //ndwi
        ParcelsVaule[i][8] = document.createTextNode(nodes[i].attributes[10].nodeValue); //tvi
        ParcelsVaule[i][9] = document.createTextNode(nodes[i].attributes[11].nodeValue); //ndvi
        ParcelsVaule[i][10] = document.createTextNode(nodes[i].attributes[12].nodeValue); //NSI
        ParcelsVaule[i][11] = document.createTextNode(nodes[i].attributes[13].nodeValue);//WI
        ParcelsVaule[i][12] = document.createTextNode(nodes[i].attributes[14].nodeValue);//NDGI
        ParcelsVaule[i][13] = document.createTextNode(nodes[i].attributes[15].nodeValue);//GEWI
        ParcelsVaule[i][14] = document.createTextNode(nodes[i].attributes[16].nodeValue);//EVI
        ParcelsVaule[i][15] = document.createTextNode(nodes[i].attributes[17].nodeValue);//,RVI
        ParcelsVaule[i][16] = document.createTextNode(nodes[i].attributes[18].nodeValue);//,ARVI
        ParcelsVaule[i][17] = document.createTextNode(nodes[i].attributes[19].nodeValue);//,SAVI
        ParcelsVaule[i][18] = document.createTextNode(nodes[i].attributes[20].nodeValue);//,MSAVI
        ParcelsVaule[i][19] = document.createTextNode(nodes[i].attributes[21].nodeValue);//,DVI
        ParcelsVaule[i][20] = document.createTextNode(nodes[i].attributes[22].nodeValue);//,RDVI
    }
    
    gmap.clearOverlays();
    //var marker = new Array();
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var strHtml = "<table><tr><td>";
        strHtml += "地块编号：</td><td>" + ParcelsVaule[i][0].nodeValue + "</td></tr><tr><td>";
        strHtml += "经度：</td><td>" + pointLocation.x + "</td></tr><tr><td>";
        strHtml += "纬度：</td><td>" + pointLocation.y + "</td></tr><tr><td>";
        strHtml += "红边反射率：</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr><tr><td>";
        strHtml += "吸收谷深度：</td><td>" + ParcelsVaule[i][4].nodeValue + "</td></tr><tr><td>";
        strHtml += "吸收谷波长：</td><td>" + ParcelsVaule[i][5].nodeValue + "</td></tr><tr><td>";
        strHtml += "吸收谷宽度：</td><td>" + ParcelsVaule[i][6].nodeValue + "</td></tr>";
        strHtml += "</table>";
        
        createMarker(pointLocation, gmap, strHtml);
    }
    
    
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    
    with($("#infoTable"))
    {
        empty();
        append(divTable);
        css("visibility", "visible");
    }
    $("#DivMenuControl").css("visibility", "visible");
    hideWaitImage();

}


//***************************************************************灾害监测-干旱 lb090409*****************************************************************************************
//加载旱情样点观测数据
function loadSamplePointsTable_drought()
{
    var imageId = $("#ImageListSelect").val();
    
    var type=$("#forDatacache").data("calculateType");
    
    if(gMapListen) removeListener();
    
    var strURL = "services/getSamplePoints_disease.aspx";
    
    $.get(strURL,{IMAGEID:imageId,TYPE:type,tmp:Math.random()},function(data){
        var xmlDocument = data.documentElement;
        
        var nodes = xmlDocument.getElementsByTagName("Point");
        var nodeNumber = nodes.length;
        if(nodeNumber < 1)
        {
            alert("该区域没有相对应的土壤含水量样点数据，请重新选择！");
            return;
        }
        
        markerSampleDroughtPoints(xmlDocument);
    });
}

//显示旱情样点数据
function markerSampleDroughtPoints(xmlDocument)
{        
    var tableTitleNames = new Array("地块编号","经度","纬度","土壤含水量0-5cm","土壤含水量10-20cm","土壤含水量20-30cm");
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    
    var nodes = xmlDocument.getElementsByTagName("Point");
    
    var ParcelsNumber = nodes.length;
    var ParcelsVaule = new Array();
    
    for(var i = 0; i < ParcelsNumber; i++)
    {
        ParcelsVaule[i] = new Array();
        
        for (var j = 0; j < tableTitles.length; j++)
        {
            ParcelsVaule[i][j] = document.createTextNode(nodes[i].attributes[j].nodeValue);
        }
    }
    
    
    gmap.clearOverlays();
    //var marker = new Array();
    var DLon,DLat,MLon,MLat,SLon,SLat;
    
    var lat = "";
    var lng = "";
    
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var dmsPoint = tranGLatLngToDMS(pointLocation);
        
        lat = ParcelsVaule[0][2].nodeValue;
        lng = ParcelsVaule[0][1].nodeValue;
        
        var strHtml = "<table><tr><td>";
        strHtml += "地块编号：</td><td>" + ParcelsVaule[i][0].nodeValue + "</td></tr><tr><td>";
        strHtml += "经度：</td><td>" + dmsPoint[0] + "</td></tr><tr><td>"; //pointLocation.x  
        strHtml += "纬度：</td><td>" +  dmsPoint[1] + "</td></tr><tr><td>";//pointLocation.y
        strHtml += "土壤含水量0-5cm：</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr><tr><td>";
        strHtml += "土壤含水量10-20cm：</td><td>" + ParcelsVaule[i][4].nodeValue + "</td></tr><tr><td>";
        strHtml += "土壤含水量20-30cm：</td><td>" + ParcelsVaule[i][5].nodeValue + "</td></tr>";
        strHtml += "</table>";
        
        createMarker(pointLocation, gmap, strHtml);
    }
    
    //设置地图中心随样点位置改变
    var centerPoint = new GLatLng(lat, lng);
    gmap.setCenter(centerPoint, 9);
    
       
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    //$(table).addClass("viewTable");
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    $("#infoTable").empty();
    document.getElementById("infoTable").appendChild(divTable);
    document.getElementById("infoTable").style.visibility = "visible";
    document.getElementById("DivMenuControl").style.visibility = "visible";
    
}

//显示样点旱情指数
function markerSampleRSPoints_Drought(xmlDocument)
{
    var tableTitleNames = new Array("地块编号","经度","纬度","NDWI", "SPSI","TVDI", "VSWI");
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    var nodes = xmlDocument.getElementsByTagName("Parcel");
    var ParcelsNumber = nodes.length;//xmlDocument.childNodes.length;   
    
    var ParcelsVaule = new Array();
    
    for(var i = 0; i < ParcelsNumber; i++)
    {
        ParcelsVaule[i] = new Array();
        ParcelsVaule[i][0] = document.createTextNode(nodes[i].attributes[0].nodeValue);  //pointid
        ParcelsVaule[i][1] = document.createTextNode(nodes[i].attributes[1].nodeValue); //lat
        ParcelsVaule[i][2] = document.createTextNode(nodes[i].attributes[2].nodeValue); //lon
        ParcelsVaule[i][3] = document.createTextNode(nodes[i].attributes[5].nodeValue); //NDWI
        ParcelsVaule[i][4] = document.createTextNode(nodes[i].attributes[6].nodeValue); //SPSI
        ParcelsVaule[i][5] = document.createTextNode(nodes[i].attributes[7].nodeValue); //TVDI
        ParcelsVaule[i][6] = document.createTextNode(nodes[i].attributes[8].nodeValue); //VSWI
    }
    
    gmap.clearOverlays();
    //var marker = new Array();
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var strHtml = "<table><tr><td>";
        strHtml += "地块编号：</td><td>" + ParcelsVaule[i][0].nodeValue + "</td></tr><tr><td>";
        strHtml += "经度：</td><td>" + pointLocation.x + "</td></tr><tr><td>";
        strHtml += "纬度：</td><td>" + pointLocation.y + "</td></tr><tr><td>";
        strHtml += "NDWI：</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr><tr><td>";
        strHtml += "SPSI：</td><td>" + ParcelsVaule[i][4].nodeValue + "</td></tr><tr><td>";
        strHtml += "TVDI：</td><td>" + ParcelsVaule[i][5].nodeValue + "</td></tr><tr><td>";
        strHtml += "VSWI：</td><td>" + ParcelsVaule[i][6].nodeValue + "</td></tr>";
        strHtml += "</table>";
        
        createMarker(pointLocation, gmap, strHtml);
    }
    
    
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    //$(table).addClass("viewTable");
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    
    with($("#infoTable"))
    {
        empty();
        append(divTable);
        css("visibility", "visible");
    }
    $("#DivMenuControl").css("visibility", "visible");
    hideWaitImage();

}
